import request from '@u/request.js'

// eslint-disable-next-line no-unused-varsss
export function testScopeRow(row) {
  console.log(row.areaName, 1)
}

// 注册设备
export function register(data) {
  return request({
    url: '/device/api/v2/deviceInfo/register',
    method: 'post',
    data
  })
}

// 下载批量注册模板
export function downloadTemplate(params) {
  return request({
    url: '/device/api/v2/deviceInfo/downloadDeviceTemplate/' + params,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  })
}

// 设备信息更新
export function updateDeviceInfo(data) {
  return request({
    url: '/device/api/v2/deviceInfo/update',
    method: 'post',
    data
  })
}

// 获取所有的设备类型
export function getDeviceKinds() {
  return request({
    url: '/core/api/data/getDataList',
    method: 'post',
    data: {
      'parentCode': 'DEVICE_TYPE'
    }
  })
}

// 获取用户当前机构及下级机构
export function getOrgList(orgId) {
  return request({
    url: '/core/api/org/getOrgTreeByDistinctId/' + orgId,
    method: 'get'
  })
}

// 获取机构信息
export function getOrgById(orgId) {
  return request({
    url: '/core/api/org/getOrgByOrgId/' + orgId,
    method: 'get'
  })
}

// 查询父级区域信息
export function getAreaInfo(areaId) {
  return request({
    url: '/core/api/region/getParentRegionListById/' + areaId,
    method: 'get'
  })
}

// 批量注册
export function regitstDevicesBatch(data, id) {
  return request({
    url: '/device/api/v2/deviceInfo/batchRegister/' + id,
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data
  })
}

// 下载批量注册结果
export function getTemplateRegisterState(id) {
  return request({
    url: '/device/api/v2/deviceInfo/downloadDeviceLogById/' + id,
    method: 'get',
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    }
  })
}

